# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets
from gui.data_analysis.delete_wafer_info_setting import Ui_Dialog
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *


class DeleteWaferInfoWindow(QtWidgets.QDialog, Ui_Dialog):
    dialogSignal = pyqtSignal(object)

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        icon = QIcon()

        icon.addPixmap(
            QPixmap("icons/logo.ico"),
            QIcon.Normal,
            QIcon.Off)
        self.setWindowIcon(icon)

    def set_data_2_combox(self, wafer_list):
        self.cbb_wafer.clear()
        self.cbb_wafer.addItems(wafer_list)

    @pyqtSlot()
    def on_btnEnsure_clicked(self):
        wafer_info = self.cbb_wafer.currentText().strip()
        if wafer_info:
            self.dialogSignal.emit(wafer_info)
            self.close()
        else:
            self.show_notification("提示", "查询条件不能为空")

    def show_notification(self, title, content):
        QMessageBox.information(self, title, content, QMessageBox.Yes, QMessageBox.Yes)

    @pyqtSlot()
    def on_btnCancel_clicked(self):
        self.close()
